﻿// See https://aka.ms/new-console-template for more information

using System;

namespace Summation1
{
    class Program1
    {
        //求最大值
        public void Max(int[] nums,int n)
        {
            int max = -0xfffffff;
            for (int i = 0; i < n; i++)
            {
                if (max < nums[i])
                {
                    max = nums[i];
                }
            }
            Console.WriteLine("整数数组的最大值是：{0}",max);
        }
        //求最小值
        public void Min(int[] nums,int n)
        {
            int min = 0xfffffff;
            for (int i = 0; i < n; i++)
            {
                if (min > nums[i]) min = nums[i];
            }
            Console.WriteLine("整数数组的最小值是：{0}",min);
        }
        //求所有数组元素之和
        public int Sum(int[] nums,int n)
        {
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += nums[i];
            }
            Console.WriteLine("整数数组的元素之和是：{0}",sum);
            return sum;
        }
        //求平均值
        public void Average(int sum, int n)
        {
            int average = sum / n;
            Console.WriteLine("整数数组的平均值是：{0}",average);
        }
    }

    class test
    {
        static void Main(string[] args)
        {
            int n;
            int i=0;
            Console.WriteLine("请输入数组的个数");
            n=Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入数组值");
            int[] nums = new int[n];
            while (i<n)
            {
                nums[i] = Convert.ToInt32(Console.ReadLine());
                i++;
            }
            Program1 p = new Program1();
            p.Max(nums,n);
            p.Min(nums,n);
            int sum=p.Sum(nums,n);
            p.Average(sum,n);
        }
    }
}



